define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable', 'echarts', 'echarts-theme'], function ($, undefined, Backend, Table, Form, undefined, Echarts, undefined) {

    var Controller = {
        index: function () {
            // 初始化表格參數配置
            Table.api.init({
                extend: {
                    index_url: 'jdy/sdbiao/index',
                    add_url: 'jdy/sdbiao/add',
                    edit_url: 'jdy/sdbiao/edit',
                    del_url: 'jdy/sdbiao/del',
                    multi_url: 'jdy/sdbiao/multi',
                    table: 'jdy_sdbiao',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                showToggle: false,
                showColumns: true,
                showExport: false,
                searchFormVisible: true,
                columns: [
                    [
                        //{checkbox: true},
                        //{field: 'id', title: __('Id')},
                        //{field: 'anchang_id', title: __('Anchang_id')},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'addtabs',
                                    title: __('詳情'),
                                    classname: 'btn btn-xs btn-warning btn-addtabs',
                                    icon: 'fa fa-laptop',
                                    url: 'jdy/sdblog/index'
                                }
                            ],
                            formatter: Table.api.formatter.operate
                        },
                        {field: 'sdtype.name', title: __('类型')},
                        {field: 'biaohao', title: __('Biaohao'), operate: false},
                        {field: 'anchang.name', title: __('Anchang.name'), operate: false},
                        {field: 'name', title: __('Name'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images, operate:false},
                        //{field: 'create_time', title: __('Create_time'), operate:false},
                        {field: 'sdblog_update_time', title: __('Update_time'), operate:false}
                        //{field: 'anchang.id', title: __('Anchang.id')},
                        //{field: 'anchang.building_id', title: __('Anchang.building_id')},
                        //{field: 'anchang.room_id', title: __('Anchang.room_id')},
                        //{field: 'anchang.name', title: __('Anchang.name')},
                        //{field: 'anchang.addr', title: __('Anchang.addr')},
                        //{field: 'anchang.remark', title: __('Anchang.remark')},
                        //{field: 'anchang.floor_no', title: __('Anchang.floor_no')},
                        //{field: 'anchang.contact1_id', title: __('Anchang.contact1_id')},
                        //{field: 'anchang.contact2_id', title: __('Anchang.contact2_id')},
                        //{field: 'anchang.companywindow_id', title: __('Anchang.companywindow_id')},
                        //{field: 'anchang.xianshi', title: __('Anchang.xianshi')},
                        //{field: 'anchang.xzq', title: __('Anchang.xzq')},
                        //{field: 'anchang.mapurl', title: __('Anchang.mapurl'), formatter: Table.api.formatter.url},
                        //{field: 'anchang.orderdate', title: __('Anchang.orderdate'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'anchang.fee', title: __('Anchang.fee')},
                        //{field: 'anchang.fee_type', title: __('Anchang.fee_type')},
                        //{field: 'anchang.pay_date', title: __('Anchang.pay_date'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'anchang.is_pay', title: __('Anchang.is_pay')},
                        //{field: 'anchang.create_time', title: __('Anchang.create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'anchang.update_time', title: __('Anchang.update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},

                    ]
                ]
            });

            // 為表格綁定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});